<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>订单数据同步</title>
<link  href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css"   rel="stylesheet" type="text/css" />
<link  href="${Plugins}/ligerUI/skins/Gray/css/all.css" 		  rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.4.4.min.js"				  type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" 				  type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.validate.min.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.metadata.js" 	  type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/messages_cn.js" 		  type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.form.js" 			  type="text/javascript"></script>
<script src="${BasePath}/res/js/ligerCommon.js"					  type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.validate.method.js" type="text/javascript"></script>
<script src="${Plugins}/datepicker/WdatePicker.js" 				  type="text/javascript"></script>

<style type="text/css">
	#searchbar {
		margin-bottom: 10px;
		margin-left: 40px;
	}
	
	.navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
	
	.l-button-submit, .l-button-test {
		width: 50px;
		float: left;
		margin-left: 10px;
		padding-bottom: 2px;
	}
</style>
</head>
<body style="padding:10px">
<div class="navbar">
		<span>您当前的位置：</span>
		多渠道订单管理 &gt;订单数据同步
</div>
<br>
<div id="searchbar"><br>
 <p><font color="red">*</font>数据同步渠道：
	<select id="syncChannel" name="syncChannel" style="width: 153px;">
   		<option value="">请选择</option>
   		<option value="0" ${syncChannel == 0 ? "selected='selected'" : ""}>京东</option>
   		<option value="1" ${syncChannel == 1 ? "selected='selected'" : ""}>淘宝</option>
   		<option value="2" ${syncChannel == 2 ? "selected='selected'" : ""}>天猫</option>
   	</select>
 </p>
 <p>
 <br/>
 <font color="red">*</font>同步开始时间：
 <input type="text" id="createStartDate" name="createStartDate" value="${startDate}" class="Wdate" value="" size="22" readonly="readonly"
			onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true,autoPickDate:true,maxDate:'#F{$dp.$D(\'createEndDate\')||\'2020-10-01\'}'})">
 <p>
 <br/>
 <font color="red">*</font>同步结束时间：
 <input type="text" id="createEndDate" name="createEndDate" value="${endDate}" class="Wdate" value="" size="22" readonly="readonly"
			onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true,autoPickDate:true,minDate:'#F{$dp.$D(\'createStartDate\')||\'2013-01-01\'}'})" >
 </p>
 <p>
 <br/>
 	<input type="button" id="btnSync"   value="同步" class="l-button-submit" />&nbsp;&nbsp;
 	<input type="button" id="btnCancel" value="取消" class="l-button-submit" />
 </p>
</div>

<script type="text/javascript">
var basePath="${BasePath}";
$(function (){
	// 同步
	$("#btnSync").click(function() {
		var syncChannel=$("#syncChannel").val();
		var startDate=$("#createStartDate").val();
		var endDate=$("#createEndDate").val();
		var params='?syncChannel='+syncChannel+'&startDate='+startDate+'&endDate='+endDate;
		if(syncChannel == "" || startDate == "" || endDate == ""){
			window.parent.f_tip("订单同步条件不能为空");
		}else{
			$.ajax({
		   		 type:'POST',
		   		 url:basePath+'/multiChannel/syncJDOrderInfo.do'+params,
		   		 beforeSend : function() {
					 $("#searchbar").find(":submit,:button").attr("disabled", true);
					 $.ligerDialog.waitting('正在同步中,请稍候...');
				 },
		   		 success : function(data){
		   			 $.ligerDialog.closeWaitting();
		   			 if(data == 'success'){
				        window.parent.f_tip('订单信息同步成功');
		   		     }else{
		          		window.parent.f_tip(data);
		   		     }
		   			 $("#searchbar").find(":submit,:button").removeAttr("disabled");
				 },
				 error : function() {
					 $.ligerDialog.closeWaitting();
					 $.ligerDialog.alert('请求异常');
					 $("#searchbar").find(":submit,:button").removeAttr("disabled");
				 }
	   		});
		}
	});	
	
	// 取消
	$("#btnCancel").click(function() {
		close_liger_tab();
	});
});
</script>
</body>
</html>